using System.Globalization;
using System.Windows;
using System.Windows.Data;
using System.Windows.Media;

namespace IMClient.Converters
{
    // 状态到可见性的转换器（用于已处理状态的显示）
    public class StatusToVisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is string status)
            {
                return status != "待处理" ? Visibility.Visible : Visibility.Collapsed;
            }
            return Visibility.Collapsed;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

    // 待处理状态到可见性的转换器（用于按钮的显示）
    public class PendingStatusToVisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is string status)
            {
                return status == "待处理" ? Visibility.Visible : Visibility.Collapsed;
            }
            return Visibility.Collapsed;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

    // 非待处理状态到可见性的转换器（用于状态文本的显示）
    public class NonPendingStatusToVisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is string status)
            {
                return status != "待处理" ? Visibility.Visible : Visibility.Collapsed;
            }
            return Visibility.Collapsed;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

    // 状态到颜色的转换器
    public class StatusToColorConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is string status)
            {
                return status switch
                {
                    "等待验证" => new SolidColorBrush(Color.FromRgb(102, 102, 102)),  // #666666 灰色
                    "已同意" => new SolidColorBrush(Color.FromRgb(7, 193, 96)),       // #07C160 绿色
                    "已拒绝" => new SolidColorBrush(Color.FromRgb(245, 108, 108)),    // #F56C6C 红色
                    "对方已同意" => new SolidColorBrush(Color.FromRgb(7, 193, 96)),   // #07C160 绿色
                    "对方已拒绝" => new SolidColorBrush(Color.FromRgb(245, 108, 108)),// #F56C6C 红色
                    _ => new SolidColorBrush(Color.FromRgb(153, 153, 153))            // #999999 默认灰色
                };
            }
            return new SolidColorBrush(Color.FromRgb(153, 153, 153));
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
} 